# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-net-ldap
_gemname=net-ldap
pkgver=0.16.2
pkgrel=2
pkgdesc="Pure Ruby LDAP library"
url="https://github.com/ruby-ldap/ruby-net-ldap"
arch="noarch"
license="MIT"
depends="ruby"
checkdepends="ruby-bundler"
source="https://github.com/ruby-ldap/$pkgname/archive/v$pkgver/$pkgname-$pkgver.tar.gz
	gemspec.patch
	"
builddir="$srcdir/$pkgname-$pkgver"

build() {
	gem build $_gemname.gemspec
}

check() {
	# TODO: Install from aports after we create aport for flexmock.
	export GEM_HOME="$(pwd)/.gems"
	bundle install

	"$GEM_HOME"/bin/rake test
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"

	gem install --local \
		--install-dir "$gemdir" \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname

	# Remove unnecessary files and empty directories.
	cd "$gemdir"
	rm -r cache build_info doc
}

sha512sums="fc32ec6ec7e5819ac116450cf4ab3a55fea2dc3ae144c3a3b7293b70169b9a9ddfb554002e38b2da4ab1d8be698552cd1eae61d916d623aced353701f43d8c2c  ruby-net-ldap-0.16.2.tar.gz
b1fbdfac461cd765bc20731f835873570c57be1188cc26099e5b26d74abd6a3e9a2848cf180825f1715897808bc77e1c7ac1b62a7980eee597b88e2b6d68168f  gemspec.patch"
